#include <bits/stdc++.h>

using namespace std;

class MyStack {
	queue<int> in;
	queue<int> out;

public:
	MyStack() { }

	void push(int x) {
		in.emplace(x);
		while (!out.empty()) {
			in.emplace(out.front());
			out.pop();
		}
		swap(in, out);
	}

	int pop() {
		int res = out.front();
		out.pop();
		return res;
	}

	int top() {
		int res = out.front();
		return res;
	}

	bool empty() {
		return out.empty();
	}
};

int main()
{
	return 0;
}
